<?php

include_once 'Classes/PHPCodeProvider.php';

/*
 * Create an instance of the CodeGeneratorOptions class
 * using the default options for code generation.
 */

$options = new CodeGeneratorOptions();

/*
 * Create an instance of the IndentedTextWriter.
 */

$writer = new IndentedTextWriter();

/*
 * Create several PrimitiveExpression instance
 */

$primitive1 = new PrimitiveExpression(3.14);
$primitive2 = new PrimitiveExpression(10000);
$primitive3 = new PrimitiveExpression(0x1A);
$primitive4 = new PrimitiveExpression(true);
$primitive5 = new PrimitiveExpression('some string');
$primitive6 = new PrimitiveExpression(null);
$primitive7 = new PrimitiveExpression(1e4);

$provider = new PHPCodeProvider();

$provider->generateCodeFromExpression($primitive1, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive2, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive3, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive4, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive5, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive6, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

$writer->clear();

$provider->generateCodeFromExpression($primitive7, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

/*
 * The output should be :
 * 
 * 3.14
 *
 * 10000
 *
 * 26
 *
 * true
 *
 * 'some string'
 *
 * null
 * 
 * 10000
 */

?>
